home *** CD-ROM | disk | FTP | other *** search
/ Star Trek Starfleet Academy Mini Omnipedia / MINI_OMNI.ISO / pc / omni_v2.dxr / 00384_Keystroke Input.ls < prev    next >
Encoding:
Text File  |  1996-04-15  |  5.4 KB  |  199 lines

  1. global gInputFieldSpr, gInputField, gPrevKeyInChars, oIndexScroller, gModeState, gAlphaState, gGlobalStepCount, gPrevTmOutScript, gKeyTmOutLengthK, gTimeRunningF, gIndxScrollFldK, gSearchState, oIndexMediator, gOurFontK, gHoldSearchInfo, oINTERfaceFind, gActiveWin, gIJustHitReturn, gTopicNameField, oImport
  2.  
  3. on hInitInputParams
  4.   set gInputField to the number of cast "searchtextcandidate"
  5.   set the editableText of sprite gInputFieldSpr to 1
  6.   set the keyDownScript to "hKeyCheck"
  7.   set the text of field gInputField to " "
  8.   set gPrevKeyInChars to EMPTY
  9.   set gKeyTmOutLengthK to 60
  10.   set the timeoutScript to EMPTY
  11.   set gPrevTmOutScript to EMPTY
  12.   set gIJustHitReturn to 0
  13. end
  14.  
  15. on hKeyCheck
  16.   global gEditKeys
  17.   set vKey to the key
  18.   set vKeyVal to charToNum(vKey)
  19.   hKeyEventSupervisor()
  20.   if gEditKeys then
  21.     if the shiftDown and the commandDown and (vKey = ">") then
  22.       hReadLinkFromList(1)
  23.       return 
  24.     end if
  25.     if the shiftDown and the commandDown and (vKey = "<") then
  26.       hReadLinkFromList(-1)
  27.       return 
  28.     end if
  29.   end if
  30.   if the shiftDown then
  31.     if vKeyVal = 29 then
  32.       hStepNext()
  33.       return 
  34.     end if
  35.     if vKeyVal = 28 then
  36.       hStepPrev()
  37.       return 
  38.     end if
  39.     if vKeyVal = 30 then
  40.       mIndexSliderKeyPage(oIndexScroller, -8)
  41.       return 
  42.     end if
  43.     if vKeyVal = 31 then
  44.       mIndexSliderKeyPage(oIndexScroller, 8)
  45.       return 
  46.     end if
  47.   end if
  48.   if the commandDown then
  49.     if vKey = "F" then
  50.       mPopSearchStrip(oINTERfaceFind)
  51.       return 
  52.     end if
  53.     if vKey = "Q" then
  54.       hBolt()
  55.       return 
  56.     end if
  57.     if vKey = "W" then
  58.       if vKey = "W" then
  59.         hWinCloser()
  60.         return 
  61.       end if
  62.       return 
  63.     end if
  64.   end if
  65.   if vKey = RETURN then
  66.     dontPassEvent()
  67.     hSearchRequest()
  68.     set gIJustHitReturn to 1
  69.     return 
  70.   end if
  71.   if gHoldSearchInfo then
  72.     if (vKeyVal = 8) or (vKeyVal = 28) or (vKeyVal = 29) or (vKeyVal = 32) then
  73.       if the shiftDown and (vKeyVal = 8) then
  74.         put EMPTY into field gInputField
  75.       else
  76.         pass()
  77.       end if
  78.     else
  79.       set vStart to the selStart
  80.       set vend to the selEnd
  81.       if vStart <> vend then
  82.         put the key into char vStart + 1 to vend of field gInputField
  83.       else
  84.         put the key before char vStart + 1 of field gInputField
  85.       end if
  86.       hilite char 999 of field gInputField
  87.       dontPassEvent()
  88.       hKeyTimeMgr()
  89.       set the selStart to vStart + 1
  90.       set the selEnd to vStart + 1
  91.     end if
  92.   else
  93.     if (gModeState = #ENCY) and not (the commandDown) then
  94.       if (vKey >= "a") and (vKey <= "z") then
  95.         hKeyCallAlph()
  96.       end if
  97.     end if
  98.   end if
  99. end
  100.  
  101. on hTopicKeys
  102.   set vKey to the key
  103.   set vKeyVal to charToNum(vKey)
  104.   if the commandDown then
  105.     if vKey = "Q" then
  106.       hBolt()
  107.     end if
  108.     dontPassEvent()
  109.     return 
  110.   end if
  111.   if vKey = RETURN then
  112.     dontPassEvent()
  113.     if the text of field gTopicNameField <> EMPTY then
  114.       mEnterNewName(oImport)
  115.     end if
  116.     return 
  117.   end if
  118.   if (vKeyVal = 8) or (vKeyVal = 28) or (vKeyVal = 29) or (vKeyVal = 32) then
  119.     if the shiftDown and (vKeyVal = 8) then
  120.       put EMPTY into field gTopicNameField
  121.     end if
  122.   else
  123.     if not "~@" contains the key then
  124.       if the number of chars in field gTopicNameField < 41 then
  125.         set vStart to the selStart
  126.         set vend to the selEnd
  127.         if vStart <> vend then
  128.           put the key into char vStart + 1 to vend of field gTopicNameField
  129.         else
  130.           put the key before char vStart + 1 of field gTopicNameField
  131.         end if
  132.         hilite char 999 of field gTopicNameField
  133.         dontPassEvent()
  134.         set the selStart to vStart + 1
  135.         set the selEnd to vStart + 1
  136.       end if
  137.     end if
  138.   end if
  139. end
  140.  
  141. on hWinCloser
  142.   global oPWin
  143.   if count(the windowList) then
  144.     if string(the windowList) contains gActiveWin then
  145.       mKeyVoiceClose(oPWin)
  146.     end if
  147.   end if
  148. end
  149.  
  150. on hKeyTimeMgr
  151.   if gTimeRunningF then
  152.     set the timeoutLength to gKeyTmOutLengthK
  153.     set gIJustHitReturn to 0
  154.   else
  155.     set gPrevTmOutScript to the timeoutScript
  156.     set the timeoutLength to gKeyTmOutLengthK
  157.     set the timeoutScript to "hTrackIndextoKey"
  158.     set gTimeRunningF to 1
  159.   end if
  160. end
  161.  
  162. on hTrackIndextoKey
  163.   set the timeoutScript to EMPTY
  164.   set the timeoutScript to gPrevTmOutScript
  165.   set gTimeRunningF to 0
  166.   if gSearchState = #ENTRY then
  167.     set Lstr to char 1 to 4 of field gInputField
  168.     if Lstr = gPrevKeyInChars then
  169.       return 0
  170.     end if
  171.     set L1 to char 1 of word 1 of Lstr
  172.     if L1 <> gAlphaState then
  173.       hSetMode(#ENCY)
  174.       hputmsg(">hTrackIndextoKey requesting new Current Attr List")
  175.       hGetNewAttrList(L1, 1)
  176.     end if
  177.     set gPrevKeyInChars to Lstr
  178.     if gModeState = #EPIS then
  179.       set Lthechars to hTweaktoTitle(gPrevKeyInChars)
  180.     else
  181.       set Lthechars to gPrevKeyInChars
  182.     end if
  183.     if (gModeState = #FoundSet) and (getAt(gTrackingModeslist, 6) = 0) then
  184.       put "Sorry, there is no found entries at this time." into field "Status"
  185.     else
  186.       if not gIJustHitReturn then
  187.         set Lthechars to string(Lthechars)
  188.         if voidp(findPos(mGrabCurrAttrList(oIndexMediator, gModeState), Lthechars)) then
  189.           set Lthechars to hTryCap(string(Lthechars))
  190.           set Lnum to findPosNear(mGrabCurrAttrList(oIndexMediator, gModeState), Lthechars)
  191.         else
  192.           set Lnum to findPos(mGrabCurrAttrList(oIndexMediator, gModeState), Lthechars)
  193.         end if
  194.       end if
  195.     end if
  196.     mShiftWindowToEntry(oIndexScroller, Lnum, 1)
  197.   end if
  198. end
  199.